#pragma once

#include "Token.h"
#include "TokenManager.h"

class CScanner
{
public:
    CScanner(CTokenManager & tokenManager);

    void SetSourseCode(std::vector<char> const & sourceCode);
	void Reset();

    std::string GetValue() const;
	std::string GetPrevValue() const;
	int GetCurrLineIndex();

    CToken GetNextToken();
	CToken PeekToken();

	std::vector<std::string> GetLastTokens();
	std::string GetTokenFromEnd(int offset);

private:
    char Peek() const;
    char GetChar();

    CToken ReadNumber();
    CToken ReadKeyWordOrIdentifier();
	CToken IdentifyDoubleCharOperator(char firstHalfPperator, char secondHalfPperator, CToken token, CToken alternativeToken = CToken::INCORRECT);

    std::vector<char> m_bufferCode;
	std::string m_value, m_prevValue;
	std::vector<std::string> m_lastTokens;
	int m_currIndex;
	int m_currLineIndex;
    char m_ch;
	
	CTokenManager m_tokenManager;
};